﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Reflection;
using SGCG.Model;
using System.Windows.Data;
using System.ComponentModel;
using SGCG.Actions;

namespace SGCG
{
    public partial class SelectOptions : UserControl
    {
        private readonly SelectAction selectAction;
        private readonly TemporaryGroupingOfBorderedObjects selection;

        public SelectOptions(SelectAction selectAction)
        {
            InitializeComponent();
            this.selectAction = selectAction;
            this.selection = new TemporaryGroupingOfBorderedObjects(this.selectAction.Selection);
            this.DataContext = this;
            this.BorderOptions.IHasBorder = this.selection;
            //this.BotaoEspelhar.IsEnabled = false;

            //this.selectAction.Selection.CollectionChanged += (s, e) =>
            //{
            //    this.BotaoEspelhar.IsEnabled = (this.selectAction.Selection.Count == 1 && this.selectAction.Selection.First() is Line);             
            //};
        }

        private void BotaoMover_Click(object sender, RoutedEventArgs e)
        {
            this.selectAction.DoMove();
        }

        private void BotaoAgrupar_Click(object sender, RoutedEventArgs e)
        {
            this.selectAction.DoGroupSelection();
        }

        private void BotaoDesagrupar_Click(object sender, RoutedEventArgs e)
        {
            this.selectAction.DoUngroupSelection();
        }

        private void BotaoSelecionar_Click(object sender, RoutedEventArgs e)
        {
            this.selectAction.DoSelect();
        }

        public TemporaryGroupingOfBorderedObjects Selection
        {
            get { return this.selection; }
        }

        private void BotaoEspelhar_Click(object sender, RoutedEventArgs e)
        {
            this.selectAction.DoMirror();
        }

        private void BotaoEspelharEstatico_Click(object sender, RoutedEventArgs e)
        {
            this.selectAction.DoStaticMirror();
        }

        private void BotaoApagar_Click(object sender, RoutedEventArgs e)
        {
            this.selectAction.DoRemoveSelection();
        }

        private void BotaoRotacionar_Click(object sender, RoutedEventArgs e)
        {
            this.selectAction.DoRotate();
        }
    }
}
